﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using WXDba.Entity;
using WXDba.Abstract;
namespace WXTest2.Controllers
{
    /// <summary>
    /// 专题控制器
    /// </summary>
    public class ZhuanTiController : Controller
    {
        IYueBing _IYueBing = ConcreteFactory.GetYueBing();
        /// <summary>
        /// 中秋专题
        /// </summary>
        /// <returns></returns>
        public ActionResult ZhongQiu()
        {
            return View();
        }

        public ActionResult Result()
        {
            return PartialView();
        }
        /// <summary>
        /// 添加记录
        /// </summary>
        /// <returns></returns>
        public string Add(YueBing model)
        {
            try
            {
                model.AddTime = DateTime.Now;
                BrowserInfo info = ReqBrowser.GetBrowseInfo();
                model.Agent = info.UserAgent;
                model.Ip = info.IP;
                model.Browser = info.Browser;
                model.Version = info.BrowserVersion;
                if (_IYueBing.Add(model))
                {
                    //返回当前投票的个数
                    if (model.IsLike == null)
                    {
                        return _IYueBing.GetCount_Eat(model.Title, model.IsEat.Value).ToString();
                    }
                    else
                    {
                        return _IYueBing.GetCount_Like(model.Title, model.IsLike.Value).ToString();
                    }
                }
                return "添加记录失败";
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
    }
}